*Replacement hires
cd /OEUS/users/FEDSusers/JOLTS/
set more off

*use JOLTS_NTILDE, clear
use ./data/JOLTS_ntilde, clear


*Hires to replace quits
*Monthly
gen rep_m= 0 if emp>0 & ntilde1>0 & emp!=. & ntilde1!=. & quits1!=.
replace rep_m = hires1 if hires1<=quits1 & quits1>0 & rep_m ==0
replace rep_m = quits1 if hires1>quits1  & quits1>0 & rep_m !=. 

*Quarterly
gen rep_q = 0 if emp>0 & ntilde3>0 & emp!=. & ntilde3!=. & quits3!=.
replace rep_q = hires3 if hires3<=quits3 & quits3>0 & rep_q ==0
replace rep_q = quits3 if hires3>quits3 & quits3>0 & rep_q !=.

gen month=month(dofm(mdate))
gen year = year(dofm(mdate))
gen quarter = quarter(dofm(mdate))
gen qdate = yq(year,quarter)
keep if month==3|month==6|month==9|month==12

keep rep_q hires3 weight_f qdate
collapse (mean) hires3 rep_q (count) weight_f [aw=weight_f], by(qdate)
tsset qdate, q
gen repquitshare = rep_q/hires3
sum weight_f

keep qdate repquitshare weight_f
sum weight_f
outsheet using "/OEUS/users/FEDSusers/JOLTS/rnd2final/RepQuitShare_rnd2final.csv", replace
